﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;

namespace ConnectToDatabase
{
    public class UpdateDB : MarshalByRefObject
    {
        private string cmdtext;
        private ConnectDB connectDB = new ConnectDB();

        #region Update Loai San Pham
        public int UpdateLoaiSanPham(string MaLoaiSP, string TenLoaiSP, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.loaisanpham SET TenLoaiSanPham = '" + TenLoaiSP + "', TinhTrang = '" + TinhTrang + "' WHERE MaLoaiSanPham = '" + MaLoaiSP + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateLoaiSanPham(string MaLoaiSP, string TenLoaiSP)
        {
            cmdtext = "UPDATE dbgiaydep.loaisanpham SET TenLoaiSanPham = '" + TenLoaiSP + "' WHERE MaLoaiSanPham = '" + MaLoaiSP + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateLoaiSanPham(string MaLoaiSP, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.loaisanpham SET TinhTrang = '" + TinhTrang + "' WHERE MaLoaiSanPham = '" + MaLoaiSP + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update Nha Phan Phoi
        public int UpdateNhaPhanPhoi(string MaNhaPP, string TenNhaPP, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.nhaphanphoi SET TenNhaPP = '" + TenNhaPP + "', TinhTrang = '" + TinhTrang + "' WHERE MaNhaPP = '" + MaNhaPP + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateNhaPhanPhoi(string MaNhaPP, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.nhaphanphoi SET TinhTrang = '" + TinhTrang + "' WHERE MaNhaPP = '" + MaNhaPP + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateNhaPhanPhoi(string MaNhaPP, string TenNhaPP)
        {
            cmdtext = "UPDATE dbgiaydep.nhaphanphoi SET TenNhaPP = '" + TenNhaPP + "' WHERE MaNhaPP = '" + MaNhaPP + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update Dau San Pham
        public int UpdateDauSanPham(string MaDauSP, string MaLoaiSP, string TenDauSP, string MaNhaPP, int GiaBan, int ThoiHanBan, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.dausanpham SET MaLoaiSanPham = '" + MaLoaiSP + "', TenDauSanPham = '" + TenDauSP + "', MaNhaPP = '" + MaNhaPP + "', GiaBan = '" + GiaBan + "', ThoiHanBan = '" + ThoiHanBan + "', TinhTrang = '" + TinhTrang + "' WHERE MaDauSanPham = '" + MaDauSP + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateDauSanPham(string MaDauSP, int GiaBan, int ThoiHanBan)
        {
            cmdtext = "UPDATE dbgiaydep.dausanpham SET GiaBan = '" + GiaBan + "',ThoiHanBan= '" + ThoiHanBan +
                      "' WHERE MaDauSanPham = '" + MaDauSP + "'"; 
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update Khuyen Mai
        public int UpdateKhuyenMai(string MaKhuyenMai, string MaDauSanPham, string NoiDungKM, int PTGiamGia, string NgayBatDau, string NgayKetThuc)
        {
            cmdtext = "UPDATE dbgiaydep.khuyenmai SET MaDauSanPham = '" + MaDauSanPham + "', NoiDungKM = '" + NoiDungKM + "', PTGiamGia = '" + PTGiamGia + "', NgayBatDau = '" + NgayBatDau + "', NgayKetThuc = '" + NgayKetThuc + "' WHERE MaKhuyenMai = '" + MaKhuyenMai + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update Nhom San Pham
        public int UpdateNhomSanPham(string MaNhomSanPham, string MaDauSanPham, string MauSac, float KichThuoc, int SoLuongHienTai)
        {
            cmdtext = "UPDATE dbgiaydep.nhomsanpham SET MaDauSanPham = '" + MaDauSanPham + "', MauSac = '" + MauSac + "', KichThuoc = '" + KichThuoc + "', SoLuongHienTai = '" + SoLuongHienTai + "' WHERE MaNhomSanPham = '" + MaNhomSanPham + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateNhomSanPham(string MaNhomSanPham, int SoLuongHienTai)
        {
            cmdtext = "UPDATE dbgiaydep.nhomsanpham SET SoLuongHienTai = '" + SoLuongHienTai + "' WHERE MaNhomSanPham = '" + MaNhomSanPham + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update Phieu Nhap Hang
        public int UpdatePhieuNhapHang(string MaNhapHang, DateTime NgayNhapHang, int TongTien)
        {
            cmdtext = "UPDATE dbgiaydep.phieunhaphang SET NgayNhapHang = '" + NgayNhapHang + "', TongTien = '" + TongTien + "' WHERE MaNhapHang = '" + MaNhapHang + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdatePhieuNhapHang(string MaNhapHang, DateTime NgayNhapHang)
        {
            cmdtext = "UPDATE dbgiaydep.phieunhaphang SET NgayNhapHang = '" + NgayNhapHang + "' WHERE MaNhapHang = '" + MaNhapHang + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdatePhieuNhapHang(string MaNhapHang, int TongTien)
        {
            cmdtext = "UPDATE dbgiaydep.phieunhaphang SET TongTien = '" + TongTien + "' WHERE MaNhapHang = '" + MaNhapHang + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update CT Phieu Nhap
        public int UpdateCTPhieuNhapHang(string MaNhapHang, string MaNhomSanPham, int SoLuong, int GiaVon)
        {
            cmdtext = "UPDATE dbgiaydep.ct_phieunhaphang SET SoLuong = '" + SoLuong + "', GiaVon = '" + GiaVon + "' WHERE MaNhapHang = '" + MaNhapHang + "' AND MaNhomSanPham = '" + MaNhomSanPham + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion

        
        #region Update Phieu Tra
        public int UpdatePhieuTraHang(string MaPhieuTraHang, string NgayTra)
        {
            cmdtext = "UPDATE dbgiaydep.phieutrahang SET NgayTra = '" + NgayTra + "' WHERE MaPhieuTraHang = '" + MaPhieuTraHang + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update CT Phieu Tra
        public int UpdateCTPhieuTra(string MaPhieuTra, string MaSanPham, string ThongTinLoiSP)
        {
            cmdtext = "UPDATE dbgiaydep.ct_phieutrahang SET ThongTinLoiSP = '" + ThongTinLoiSP + "' WHERE MaPhieuTra = '" + MaPhieuTra + "' AND MaSanPham = '" + MaSanPham + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update San Pham
        public int UpdateSanPham(string MaSanPham, string MaNhomSanPham, string MaNhapHang, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.sanpham SET MaNhomSanPham = '" + MaNhomSanPham + "', MaNhapHang = '" + MaNhapHang + "', TinhTrang = '" + TinhTrang + "' WHERE MaSanPham = '" + MaSanPham + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateSanPham(string MaSanPham, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.sanpham SET TinhTrang = '" + TinhTrang + "' WHERE MaSanPham = '" + MaSanPham + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update Hoa Don
        public int UpdateHoaDon(string MaHoaDon, string NgayBan, int ThanhTien, int LoaiKhachHang, string MaNhanVienBan)
        {
            cmdtext = "UPDATE dbgiaydep.hoadon SET NgayBan = '" + NgayBan + "', ThanhTien = '" + ThanhTien + "', LoaiKhachHang = '" + LoaiKhachHang + "', MaNhanVienBan = '" + MaNhanVienBan +"' WHERE MaHoaDon = '" + MaHoaDon + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update CT Hoa Don 
        public int UpdateCTHoaDon(string MaHoaDon, string MaSanPham, int DonGiaBan)
        {
            cmdtext = "UPDATE dbgiaydep.ct_hoadon SET DonGiaBan = '" + DonGiaBan + "' WHERE MaHoaDon = '" + MaHoaDon + "' AND MaSanPham = '" + MaSanPham + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update DV Bao Hanh
        public int UpdateDVBaoHanh(string MaDVBaoHanh, string MaHoaDon, string MaSanPham, DateTime NgayNhanBaoHanh, DateTime NgayTraSanPham, string HoTenKhachHang, string CMND, int PhiPhatSinh)
        {
            cmdtext = "UPDATE dbgiaydep.dv_baohanh SET MaHoaDon = '" + MaHoaDon + "', MaSanPham = '" + MaSanPham + "', NgayNhanBaoHanh = '" + NgayNhanBaoHanh + "', NgayTraSanPham = '" + NgayTraSanPham + "', CMND = '" + CMND + "', PhiPhatSinh = '" + PhiPhatSinh + "' WHERE MaDVBaoHanh = '" + MaDVBaoHanh + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateDVBaoHanh(string MaDVBaoHanh, DateTime NgayTraSanPham)
        {
            cmdtext = "UPDATE dbgiaydep.dv_baohanh SET NgayTraSanPham = '" + NgayTraSanPham + "' WHERE MaDVBaoHanh = '" + MaDVBaoHanh + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update Loai Nhan Vien
        public int UpdateLoaiNhanVien(string MaLoaiNhanVien, string TenLoaiNhanVien, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.loainhanvien SET TenLoaiNhanVien = '" + TenLoaiNhanVien + "', TinhTrang = '" + TinhTrang + "' WHERE MaLoaiNhanVien = '" + MaLoaiNhanVien + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateLoaiNhanVien(string MaLoaiNhanVien, string TenLoaiNhanVien)
        {
            cmdtext = "UPDATE dbgiaydep.loainhanvien SET TenLoaiNhanVien = '" + TenLoaiNhanVien + "' WHERE MaLoaiNhanVien = '" + MaLoaiNhanVien + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateLoaiNhanVien(string MaLoaiNhanVien, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.loainhanvien SET TinhTrang = '" + TinhTrang + "' WHERE MaLoaiNhanVien = '" + MaLoaiNhanVien + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update Nhan Vien
        public int UpdateNhanVien(string MaNhanVien, string MaLoaiNhanVien, string TenNhanVien, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.nhanvien SET MaLoaiNhanVien = '" + MaLoaiNhanVien + "', TenNhanVien = '" + TenNhanVien + "', TinhTrang = '" + TinhTrang + "' WHERE MaNhanVien = '" + MaNhanVien + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateNhanVien(string MaNhanVien, int TinhTrang)
        {
            cmdtext = "UPDATE dbgiaydep.nhanvien SET TinhTrang = '" + TinhTrang + "' WHERE MaNhanVien = '" + MaNhanVien + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateNhanVien_MaLoaiNV(string MaNhanVien, string MaLoaiNhanVien)
        {
            cmdtext = "UPDATE dbgiaydep.nhanvien SET MaLoaiNhanVien = '" + MaLoaiNhanVien + "' WHERE MaNhanVien = '" + MaNhanVien + "'";
            return connectDB.QueryData(cmdtext);
        }

        public int UpdateNhanVien_TenNV(string MaNhanVien, string TenNhanVien)
        {
            cmdtext = "UPDATE dbgiaydep.nhanvien SET TenNhanVien = '" + TenNhanVien + "' WHERE MaNhanVien = '" + MaNhanVien + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion


        #region Update Dang Nhap
        public int UpdateDangNhap(string MaDangNhap, string MaNhanVien, string ThoiGianDangNhap)
        {
            cmdtext = "UPDATE dbgiaydep.dangnhap SET ThoiGianDangNhap = '" + ThoiGianDangNhap + "' , MaNhanVien = '" + MaNhanVien + "' WHERE MaDangNhap = '" + MaDangNhap + "'";
            return connectDB.QueryData(cmdtext);
        }
        public int UpdateDangNhap(string MaDangNhap, string ThoiGianDangXuat)
        {
            cmdtext = "UPDATE dbgiaydep.dangnhap SET ThoiGianDangXuat = '" + ThoiGianDangXuat + "' WHERE MaDangNhap = '" + MaDangNhap + "'";
            return connectDB.QueryData(cmdtext);
        }
        #endregion



        #region Update Cac Tham So <--- Chua Code
        #endregion


        public int Test() { return 0; }
    }
}
